import {
  legacy_createStore as createStore,
  combineReducers,
  applyMiddleware,
} from 'redux';

// 导入中间件，处理函数形式的action
import thunk from 'redux-thunk';

// 接入 redux 插件
import { composeWithDevTools } from 'redux-devtools-extension';

// 登录reducer
import { login } from './reducers/login';
// 用户reducer
import { user } from './reducers/user';
// 文章reducer
import { article } from './reducers/article';

// 整个项目reducer
const rootReducer = combineReducers({ login, user, article });

// 初始化reducer
// const initialReducer = {
//   login: localStorage.getItem('geek-pc-token') || '',
// }

export const store = createStore(
  rootReducer,
  composeWithDevTools(applyMiddleware(thunk))
);
